package com.sniper.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author suzhen
 * @create 2018/3/27
 */
@RestController
public class UploadController {

    @RequestMapping(value = "upload", method = RequestMethod.POST)
    public Map<String, Object> upload(@RequestParam("imgFile") MultipartFile imgFile, HttpServletRequest request) {
        Map<String, Object> ajaxResult = new HashMap<>(4);
        ajaxResult.put("name", imgFile.getName());
        ajaxResult.put("size", imgFile.getSize());
        ajaxResult.put("type", imgFile.getContentType());
        ajaxResult.put("method", request.getMethod());
        return ajaxResult;
    }
}
